package com.example.mongo.service;

import com.example.mongo.Model.bean.Base;
import com.example.mongo.dao.BaseMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Random;

@Service
public class BaseService {
    @Autowired
    public BaseMapper baseMapper;
    @Transactional
    public Base updataFreeComic(Base base){
        String s = "";
        Random r = new Random(1);
        for (int i = 0; i < 5; i++) {
            s = s + r.nextInt(1400);
        }
        base.setFreeComic(s);
        base = baseMapper.save(base);
        return base;
    }


    public List<Base> getBase(){
        return baseMapper.findAll();
    }

}
